package Text_48;

public class Code {

	public static void main(String[] args) {
		 Circle c = new Circle(5);
	        Square s = new Square(4);
	        System.out.println("Circle Area ："+c.calculateArea());
	        System.out.println("Circle Perimeter ："+c.calculatePerimeter());
	        System.out.println("Square Area ："+s.calculateArea());
	        System.out.println("Square Perimeter ："+s.calculatePerimeter());
	    }
	}
	interface  Shape{
	    double calculateArea();
	}
	 abstract class AbstractShape implements Shape{
	    abstract double calculatePerimeter();
	}
	class Circle extends AbstractShape{
	    private double r;
	    public Circle(double r){
	        this.r = r;
	    }
	    //求面积
	    public double calculateArea() {
	        double s = 3.14*r*r;
	        return s;
	    }
	    //求周长
	    double calculatePerimeter() {
	        double z = 2*3.14*r;
	        return z;
	    }
	}
	class Square extends AbstractShape{
	    private double b;
	    public Square(double b){
	        this.b = b;
	    }

	    public double calculateArea() {
	        double s = b*b;
	        return s;
	    }
	    double calculatePerimeter() {
	        double z = 4*b;
	        return z;

	}

}
